package com.selfdiscipline.di

import android.content.Context
import androidx.room.Room
import com.selfdiscipline.data.local.AppDatabase
import com.selfdiscipline.data.repository.HabitRepositoryImpl
import com.selfdiscipline.data.repository.TaskRepositoryImpl
import com.selfdiscipline.data.repository.TimeRecordRepositoryImpl
import com.selfdiscipline.data.repository.TimerRepositoryImpl
import com.selfdiscipline.domain.repository.HabitRepository
import com.selfdiscipline.domain.repository.TaskRepository
import com.selfdiscipline.domain.repository.TimeRecordRepository
import com.selfdiscipline.domain.repository.TimerRepository
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object AppModule {
    
    @Provides
    @Singleton
    fun provideAppDatabase(@ApplicationContext context: Context): AppDatabase {
        return Room.databaseBuilder(
            context,
            AppDatabase::class.java,
            "self_discipline_db"
        ).build()
    }
    
    @Provides
    @Singleton
    fun provideTaskRepository(database: AppDatabase): TaskRepository {
        return TaskRepositoryImpl(database.taskDao())
    }
    
    @Provides
    @Singleton
    fun provideHabitRepository(database: AppDatabase): HabitRepository {
        return HabitRepositoryImpl(database.habitDao())
    }
    
    @Provides
    @Singleton
    fun provideTimeRecordRepository(database: AppDatabase): TimeRecordRepository {
        return TimeRecordRepositoryImpl(database.timeRecordDao())
    }
    
    @Provides
    @Singleton
    fun provideTimerRepository(database: AppDatabase): TimerRepository {
        return TimerRepositoryImpl(database.timeRecordDao())
    }
} 